#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 1e6 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n;
ll a[N];
ll b[N];
ll qmi(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b % 2) res = res * a;
		a = a * a;
		b /= 2;
	}
	return res;
}

ll qmi(ll a, ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2) res=res*a;
		a=a*a;
		b/=2;
	}
	return res;
}
int main()
{
	close();
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[0]=1;

	ll ans = 0;
	vector<int> v;
	v.push_back(0);
	bool ok = false;
	for (int i = 1; i <= n; i++)
	{
		
	}


	int m = v.size();
	for (int i = 1; i < m; i++)
	{
		if (i == m - 1 && ok) break;
		else if (i == 1 && i + 1 < m)
		{
			ans += qmi(2, v[2] - 2);
		}
		else if (i + 1 < m)
		{
			ans += qmi(2, v[i + 1] - v[i - 1] - 2);
		}
		else if (i == m - 1)
		{
			ans += qmi(2, v[i] - v[i - 1] - 1);
		}

	}

	cout << ans << '\n';

	return 0;
}